package com.ggh.jinjilive.remotedata;

import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import com.ggh.jinjilive.remotedata.systemapi.SystemApiService;
import com.ggh.jinjilive.ui.create.CreateLiveViewModel;
import com.ggh.jinjilive.ui.home.follow.FollowViewModel;
import com.ggh.jinjilive.ui.home.live.LiveViewModel;
import com.ggh.jinjilive.ui.home.video.VideoViewModel;
import com.ggh.jinjilive.ui.home.video.videoplay.VideoPlayViewModel;
import com.ggh.jinjilive.ui.home.voice.VoiceViewModel;
import com.ggh.jinjilive.ui.live.AudienceLiveViewModel;
import com.ggh.jinjilive.ui.live.TVLiveViewModel;
import com.ggh.jinjilive.ui.login.LoginViewModel;
import com.ggh.jinjilive.ui.mall.collection.CollectionViewModel;
import com.ggh.jinjilive.ui.mall.goods.GoodsViewModel;
import com.ggh.jinjilive.ui.mall.goods.affirm.AffirmOrderViewModel;
import com.ggh.jinjilive.ui.mall.goods.details.GoodsDetailsViewModel;
import com.ggh.jinjilive.ui.mall.order.OrderViewModel;
import com.ggh.jinjilive.ui.mall.shop.MineShopViewModel;
import com.ggh.jinjilive.ui.mall.shop.ShopViewModel;
import com.ggh.jinjilive.ui.mall.shopping.ShopPingCarViewModel;
import com.ggh.jinjilive.ui.mine.MineViewModel;
import com.ggh.jinjilive.ui.mine.TaskReceiveViewModel;
import com.ggh.jinjilive.ui.mine.address.TheGoodsViewModel;
import com.ggh.jinjilive.ui.mine.personal.PersonalDataViewModel;
import com.ggh.jinjilive.ui.mine.zhubo.ZhuBoViewModel;
import com.ggh.jinjilive.ui.social.near.NearViewModel;
import com.ggh.jinjilive.ui.social.record.ExamineViewModel;

import javax.inject.Inject;



public class ViewModelFactory implements ViewModelProvider.Factory {

    private SystemApiService apiCallInterface;

    @Inject
    public ViewModelFactory(SystemApiService apiCallInterface) {
        this.apiCallInterface = apiCallInterface;
    }


    @NonNull
    @Override
    public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
        if (modelClass.isAssignableFrom(LoginViewModel.class)) {
            return (T) new LoginViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(LiveViewModel.class)) {
            return (T) new LiveViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(VideoViewModel.class)) {
            return (T) new VideoViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(VoiceViewModel.class)) {
            return (T) new VoiceViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(FollowViewModel.class)) {
            return (T) new FollowViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(NearViewModel.class)) {
            return (T) new NearViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(ExamineViewModel.class)) {
            return (T) new ExamineViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(GoodsViewModel.class)) {
            return (T) new GoodsViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(CreateLiveViewModel.class)) {
            return (T) new CreateLiveViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(TVLiveViewModel.class)) {
            return (T) new TVLiveViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(AudienceLiveViewModel.class)) {
            return (T) new AudienceLiveViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(VideoPlayViewModel.class)) {
            return (T) new VideoPlayViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(PersonalDataViewModel.class)) {
            return (T) new PersonalDataViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(GoodsDetailsViewModel.class)) {
            return (T) new GoodsDetailsViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(AffirmOrderViewModel.class)) {
            return (T) new AffirmOrderViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(TheGoodsViewModel.class)) {
            return (T) new TheGoodsViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(ShopPingCarViewModel.class)) {
            return (T) new ShopPingCarViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(OrderViewModel.class)) {
            return (T) new OrderViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(CollectionViewModel.class)) {
            return (T) new CollectionViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(ShopViewModel.class)) {
            return (T) new ShopViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(MineShopViewModel.class)) {
            return (T) new MineShopViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(MineViewModel.class)) {
            return (T) new MineViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(ZhuBoViewModel.class)) {
            return (T) new ZhuBoViewModel(apiCallInterface);
        }else if (modelClass.isAssignableFrom(TaskReceiveViewModel.class)) {
            return (T) new TaskReceiveViewModel(apiCallInterface);
        }
        throw new IllegalArgumentException("Unknown class name");
    }
}